using System;
using System.Collections;
using System.Collections.Generic;
using UnityEngine;


public class PlayerStateMachine : StateMachine
{
    [SerializeField] PlayerState[] states;                                           // PlayerState资源文件
    private Animator animator;                                                       // 获取动画组件
    void Awake()
    {
        /*************************状态信息组件***************************/
        stateTable = new Dictionary<System.Type, IState>(states.Length);
        animator = GetComponent<Animator>();
        
        // 迭代器循环获取状态
        foreach (PlayerState state in states)
        {
            // 将动画组件，刚体组件以及PlayerStateMachine传入进去
            state.Initiatize(animator,
            this);
            // 状态存入字典
            stateTable.Add(state.GetType(), state);
        }
    }
    private void Start()
    {
        // 在开始时执行Idle，进入Idle状态
        SwitchOn(stateTable[typeof(PlayerState_Idle)]);
    }
}